package com.oracle.sbdb.dao;

import org.apache.ibatis.session.SqlSession;

import com.oracle.sbdb.model.Department;

public class DepartmentDao {
	public Department selectbyId(int departmentId){
		SqlSession session = SessionFactory.getSession();
		Department res = session.selectOne("com.oracle.mybatis.DepartmentMapper.selectDepartment", departmentId);
		session.commit();
		session.close();
		return res;
	}
	
	public int selectCount() {
		SqlSession session = SessionFactory.getSession();
		int res = session.selectOne("com.oracle.mybatis.DepartmentMapper.selectDepartmentCount");
		session.commit();
		session.close();
		return res;
	}
	
	public void insert(Department Department) {
		SqlSession session = SessionFactory.getSession();
		session.selectOne("com.oracle.mybatis.DepartmentMapper.insertDepartment", Department);
		session.commit();
		session.close();
	}
	
	public void update(Department Department) {
		SqlSession session = SessionFactory.getSession();
		session.selectOne("com.oracle.mybatis.DepartmentMapper.updateDepartment", Department);
		session.commit();
		session.close();
	}
	
	public void delete(int departmentId) {
		SqlSession session = SessionFactory.getSession();
		session.selectOne("com.oracle.mybatis.DepartmentMapper.deleteDepartment", departmentId);
		session.commit();
		session.close();
	}
}
